package testes;

import java.io.File;
import java.io.IOException;

import javax.swing.JFileChooser;

public class testePaths {
	public static void main(String[] args) {
		File f;
		JFileChooser escolha = new JFileChooser();
		int escolhido = escolha.showOpenDialog(null);
		if(escolhido == JFileChooser.APPROVE_OPTION){
			f = escolha.getSelectedFile();
	
			System.out.println("Absolute Path: "+f.getAbsolutePath());
			try {
				System.out.println("Canonical Path: "+f.getCanonicalPath());
			} catch (IOException e) {
				e.printStackTrace();
			}
			
			System.out.println("Path: "+f.getPath());
			System.out.println(f.getName());
			
			
			String absolutePath = f.getAbsolutePath();
			String onlyPath = absolutePath.substring(0, absolutePath.indexOf(f.getName()));
			System.out.println(onlyPath);
		}

	}
}
